<template>
    <Layout>
        <Form ref="form1" :model="form1" :label-width="120">
            <Row class="query-form" style="padding-top: 15px">
                <Col span="8">
                    <FormItem label="审计任务：">
                        <Select v-model="form1.majorId" @on-change="selectCodingSort1">
                            <Option v-for="item in missionList" :value="item.missionId" :key="item.missionId">{{
                                item.missionName }}
                            </Option>
                        </Select>
                    </FormItem>
                </Col>
                <Col span="8">
                    <FormItem label="问题名称：">
                        <Input type="text" v-model="form1.rpoblemDesc"/>
                    </FormItem>
                </Col>
                <Col span="8">
                    <Button @click="reset" class="ivu-btn-reset">重置</Button>
                    <Button type="primary" class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
                </Col>
            </Row>

        </Form>

        <Table ref='table' :height="tableHeight" class="table" no-data-text="没有查询到相关数据！" :loading="buttonLoading"
               size="small"
               highlight-row stripe border :columns="columns1" width="100%" :data="dataTable">
        </Table>

        <Row style="margin-right:10px;">
            <Col span="24">
                <Page style="float: right" :total="pagedata.total" :page-size="pagedata.pageSize"
                      @on-change="pageChange" @on-page-size-change="pageSizeChange" :page-size-opts="pageSizeArray"
                      show-total show-sizer show-elevator/>
            </Col>
        </Row>

        <Modal title="审计问题详情" :transfer=false v-model="model3" :width=800>
            <Form :label-width="130">
                <Row>
                    <Col span='2'>
                        <b>基础信息</b>
                    </Col>
                    <Col span="19" offset="1">
                        <FormItem label="任务名称：">
                            {{showdata.planTaskName}}
                        </FormItem>
                    </Col>
                </Row>
                <Row class="detail-background-clor">
                    <Col span="19" offset="3">
                        <FormItem label="审计单位：">
                            {{showdata.auditedOrgName}}
                        </FormItem>
                    </Col>

                </Row>
                <Row>
                    <Col span="9" offset="3">
                        <FormItem label="检查人：">
                            {{showdata.auditorName}}
                        </FormItem>
                    </Col>
                    <Col span="9" offset="1">
                        <FormItem label="记录时间：" prop="auditTime">
                            {{this.formatDate(new Date(showdata.auditTime), 'yyyy-MM-dd')}}
                        </FormItem>
                    </Col>
                </Row>
                <Row class="detail-background-clor">
                    <Col span="9" offset="3">
                        <FormItem label="项目：">
                            {{showdata.factorName}}
                        </FormItem>
                    </Col>

                    <Col span="9" offset="1">
                        <FormItem label="扣分：" prop="auditScore">
                            {{showdata.auditScore}}
                        </FormItem>
                    </Col>
                </Row>

                <Row>
                    <Col span="19" offset="3">
                        <FormItem label="审计内容：">
                            {{showdata.subitemName}}
                        </FormItem>
                    </Col>
                </Row>
                <Row class="detail-background-clor">
                    <Col span="19" offset="3">
                        <FormItem label="问题描述：" prop="rpoblemDesc">
                            {{showdata.rpoblemDesc}}
                        </FormItem>
                    </Col>
                </Row>
                <Row>
                    <Col span="20" offset="3">
                        <FormItem label="问题图片:">
                            <div class="demo-upload-list" style="display:inline;margin:2px" v-for="item in upLoadList1"
                                 :key="item.id">
                                <img style="width:50px;height:50px;" @click="handleView(item.name,item.url)"
                                     :src="item.url">
                                <!--
                                <div class="demo-upload-list-cover">
                                    <Icon type="ios-eye-outline" @click.native="handleView(item.name,item.url)"></Icon>
                                </div>-->
                            </div>
                        </FormItem>
                    </Col>
                </Row>
                <hr style="margin-top: 10px;color: #dcdcdc"/>
                <Row>
                    <Col span='2'>
                        <b>整改指派</b>
                    </Col>
                    <Col span="9" offset="1">
                        <FormItem label="整改实施人：" prop="executorId">
                            {{showdata.executorName}}
                        </FormItem>
                    </Col>
                    <Col span="9" offset="1">
                        <FormItem label="整改期限（天）：" prop="rectDeadLine">
                            {{formatDate(new Date(this.showdata.rectDeadLine), 'yyyy-MM-dd')}}
                        </FormItem>
                    </Col>
                </Row>
                <Row class="detail-background-clor">
                    <Col span='20' offset="3">
                        <FormItem label="整改措施：" prop="rectMeasure">
                            {{showdata.rectMeasure}}
                        </FormItem>
                    </Col>
                </Row>
            </Form>
            <div slot="footer">
                <Button @click="model3=false" class='ivu-btn-save'>关闭</Button>
            </div>
        </Modal>
        <Modal title="审计任务选择" :transfer=false footer-hide v-model="missionSelectModal" :width=800>
            <missionSelect ref="selMission" @selectMission="selectMission">
            </missionSelect>
        </Modal>
        <Modal title="问题派发" :transfer=false v-model="model12" :width=800>
            <Form ref="viewForm" :model="form1datacopy" :rules="ruleCustom" :label-width="130">
                <Row>
                    <Col span='2'>
                        <b>基础信息</b>
                    </Col>
                    <Col span="19" offset="1">
                        <FormItem label="任务名称：">
                            {{form1datacopy.planTaskName}}
                        </FormItem>
                    </Col>

                </Row>
                <Row class="detail-background-clor">
                    <Col span="19" offset="3">
                        <FormItem label="审计单位：">
                            {{form1datacopy.auditedOrgName}}
                        </FormItem>
                    </Col>
                </Row>
                <Row>
                    <Col span="9" offset="3">
                        <FormItem label="检查人：">
                            {{form1datacopy.auditorName}}
                        </FormItem>
                    </Col>
                    <Col span="9" offset="1">
                        <FormItem label="记录时间：" prop="auditTime">
                            {{formatDate(new Date(this.form1datacopy.auditTime), 'yyyy-MM-dd')}}
                        </FormItem>
                    </Col>
                </Row>
                <Row class="detail-background-clor">
                    <Col span="9" offset="3">
                        <FormItem label="项目：">
                            {{form1datacopy.factorName}}
                        </FormItem>
                    </Col>
                    <Col span="9" offset="1">
                        <FormItem label="扣分：" prop="auditScore">
                            {{form1datacopy.auditScore}}
                        </FormItem>
                    </Col>
                </Row>

                <Row>
                    <Col span="19" offset="3">
                        <FormItem label="审计内容：">
                            {{form1datacopy.subitemName}}
                        </FormItem>
                    </Col>
                </Row>
                <Row class="detail-background-clor">
                    <Col span="20" offset="3">
                        <FormItem label="问题描述：" prop="rpoblemDesc">
                            {{form1datacopy.rpoblemDesc}}
                        </FormItem>
                    </Col>
                </Row>
                <Row>
                    <Col span="20" offset="3">
                        <FormItem label="问题图片:">
                            <div class="demo-upload-list" style="display:inline;margin:2px" v-for="item in upLoadList1"
                                 :key="item.id">
                                <img style="width:50px;height:50px;" @click="handleView(item.name,item.url)"
                                     :src="item.url">
                                <!--
                                <div class="demo-upload-list-cover">
                                    <Icon type="ios-eye-outline" @click.native="handleView(item.name,item.url)"></Icon>
                                </div>-->
                            </div>
                        </FormItem>
                    </Col>
                </Row>
                <hr style="margin-top: 10px;color: #dcdcdc"/>
                <Row style="margin-top: 10px">
                    <Col span='2'>
                        <b>整改指派</b>
                    </Col>
                    <Col span="9" offset="1">
                        <FormItem label="整改实施人：" prop="executorId">
                            <cascaderDom ref="childUser1" @setOrgInfo="setUserId1" @setOrgname="setUserName1"
                                         :currentOrgId="form1datacopy.executorId"
                                         :currentOrgName="form1datacopy.executorName">
                            </cascaderDom>
                        </FormItem>
                    </Col>
                    <Col span="9" offset="1">
                        <FormItem label="验证人：" prop="verifierId">
                            <cascaderDom ref="childUser2" @setOrgInfo="setUserId2" @setOrgname="setUserName2"
                                         :currentOrgId="form1datacopy.verifierId"
                                         :currentOrgName="form1datacopy.verifierName">
                            </cascaderDom>
                        </FormItem>
                    </Col>
                </Row>
                <Row class="detail-background-clor">
                    <Col span="9" offset="3">
                        <FormItem label="整改期限（天）：" prop="rectDeadLine">
                            <DatePicker type="date" format="yyyy-MM-dd" placeholder="请选择登陆时间"
                                        v-model="form1datacopy.rectDeadLine"></DatePicker>
                        </FormItem>
                    </Col>
                    <Col span="9" offset="1">
                    </Col>
                </Row>

                <Row>
                    <Col span="20" offset="3">
                        <FormItem label="整改措施：" prop="rectMeasure">
                            <Input v-model="form1datacopy.rectMeasure" type="textarea" :rows="3"/>
                        </FormItem>
                    </Col>
                </Row>
            </Form>
            <div slot="footer">
                <Button class='ivu-btn-save' @click="submit('viewForm')">确定</Button>
                <Button class='ivu-btn-cancel' @click="handleCancel">取消</Button>
            </div>
        </Modal>

        <Modal title="选择标准内容" :transfer=false footer-hide v-model="expertSelectModal" :width=900>
            <AuditTemplatePresetSelect ref="selExpert" @getActivityData="getActivityData"
                                       @closeModal1="closeExpertSelectModal">
            </AuditTemplatePresetSelect>
        </Modal>
        <Modal title="图片查看" v-model="visible">
            <img :src="viewUrl" v-if="visible" style="width: 100%">
            <div slot="footer">
                <Button @click="visible=false" class='ivu-btn-save'>关闭</Button>
            </div>
        </Modal>
    </layout>

</template>

<script>
    import {Api} from '@/api/index.js'
    import cascaderDom from '@/components/cascader-dom'
    import {sessionStorage} from '@/common/cacheUtils.js'
    import missionSelect from "./missionSelect.vue"
    import AuditTemplatePresetSelect from "./AuditTemplatePresetSelect.vue"

    export default {
        components: {
            cascaderDom, missionSelect, AuditTemplatePresetSelect
        },
        data() {
            const expectUserVal = (rule, value, callback) => {
                if (this.dataForm.expectUser !== null && this.dataForm.expectUser !== undefined) {
                    callback();
                } else {
                    callback(new Error(' '));
                }
            };
            const assignUserIdVal = (rule, value, callback) => {
                if (this.dataForm.assignUserId !== null && this.dataForm.assignUserId !== undefined) {
                    callback();
                } else {
                    callback(new Error(' '));
                }
            };

            return {
                missionList: [],
                model12: false,
                showdata: {},
                expertSelectModal: false,
                fileUrl: Api.interestedPartiesUserFile,
                upLoadList1: [],
                form1datacopy: {},
                missionSelectModal: false,
                form1: {},
                dataForm: {},
                chkProblem: {},
                //分页参数
                pageSizeArray: [10, 20, 50],
                pagedata: {
                    total: 0,
                    pageSize: 10,
                    currentPage: 1,
                },
                columns1: [
                    {
                        title: "序号",
                        width: 80,
                        align: "center",
                        fixed: 'left',
                        render: (h, params) => {
                            return h('span', params.index + (this.pagedata.currentPage - 1) * this.pagedata.pageSize + 1);
                        }
                    },
                    {
                        minWidth: 150,
                        title: '任务名称',
                        key: 'planTaskName',
                        align: 'center'
                    },
                    // {
                    //     minWidth: 130,
                    //     title: '检查日期',
                    //     key: 'auditTime',
                    //     align: 'center',
                    //     render:(h,params)=>{
                    //         return h('div',[
                    //             (this.formatDate(new Date(params.row.auditTime), 'yyyy-MM-dd'))
                    //         ]);
                    //     }
                    // },
                    {
                        minWidth: 400,
                        title: '问题描述',
                        key: 'rpoblemDesc',
                        align: 'center',
                    },
                    {
                        minWidth: 150,
                        title: '问题状态',
                        key: 'problemStateName',
                        align: 'center',
                    },
                    // {
                    //     minWidth: 180,
                    //     title: '问题描述',
                    //     key: 'rpoblemDesc',
                    //     align: 'center',
                    //     render: (h, params) => {
                    //         return h('div', [
                    //             h('span', (params.row.rpoblemDesc && params.row.rpoblemDesc.length) < 10 ?
                    //                 params.row.rpoblemDesc : params.row.rpoblemDesc.substr(0, 9) + '...')
                    //         ]);
                    //     }
                    // },
                    {
                        minWidth: 250,
                        title: '问题图片',
                        align: 'center',
                        key: 'imgsrc',
                        render: (h, params) => {
                            //console.log('pictureId=', params.row)
                            let ps = params.row.pictureId.split(':')

                            let hFn = []

                            ps.forEach(v => {
                                if (v) {
                                    let url = this.fileUrl + '/file/' + v
                                    hFn.push(
                                        h('img', {
                                            style: {
                                                width: "30px",
                                                margin: "3px",
                                                cursor: "pointer"
                                            },
                                            attrs: {
                                                src: url
                                            },
                                            on: {
                                                click: () => {
                                                    this.handleView('', url)
                                                }
                                            }
                                        })
                                    )
                                }
                            })
                            //console.log('222',hFn)
                            return h('div', [...hFn
                                // h('img', {
                                //         style: {
                                //             width: "30px",
                                //         },
                                //         attrs: {
                                //             src: url
                                //         }
                                // }),
                                //  h('img', {
                                //         style: {
                                //             width: "30px",
                                //         },
                                //         attrs: {
                                //             src: url
                                //         }
                                // })
                            ]);
                        }
                    },
                    {
                        title: '操作',
                        key: 'action',
                        fixed: 'right',
                        minWidth: 180,
                        align: 'center',
                        render: (h, params) => {
                            let pState = params.row.problemState
                            
                            return h('div', [
                                h('A', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px'
                                    },
                                    on: {
                                        click: () => {
                                            this.showData(params, 1);
                                        }
                                    }
                                }, '详情'),
                                h('Divider', {
                                    props: {
                                        type: 'vertical',
                                    }
                                }, ''),
                                h('A', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px',
                                        color: pState=='1' ? '' : '#d0d0d0',
                                        pointerEvents: pState=='1'  ? '' : 'none'
                                    },
                                    on: {
                                        click: () => {
                                            this.showData(params, 2);
                                        }
                                    }
                                }, '派发整改')
                            ]);
                        }
                    }
                ],
                ruleCustom: {
                    rectMeasure: {required: true, message: ' ', trigger: 'change'},
                    factorName: [{
                        required: true,
                        message: '  ',
                        trigger: 'change'
                    }],
                    executorId: [
                        {required: true, message: '  ', trigger: 'blur'}
                    ],

                },
                dataTable: [],
                model1: false,
                model11: false,
                buttonLoading: false, tableHeight: '',
                model3: false,
                viewForm: {},
                setCurrentExpectUserName: {},
                setCurrentAssignUserName: {},

                uploadList: [],
                uploadImgs: [],
                visible: false,
                viewUrl: Api.downloadPTWSchemeFile,
                upUrl: Api.uploadPTWFiles,
                editable: false,
            }
        },
        mounted: function () {
            this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 145;
            this.query();
        },
        created: function () {
            this.selectCodingSort();
        },

        methods: {
            selectCodingSort1(val) {


            },
            selectCodingSort() {
                let data = {}
                this.$http.get(Api.queryAdtMission, {params: data}).then((res) => {
                    if (res.data.data) {
                        this.missionList = res.data.data.map(v => {
                            let mission = {
                                missionId: v.missionId,
                                missionName: v.missionName
                            }
                            return mission
                        })
                    }
                })
            },
            problemStateSelect(appStatus) {
                this.form1datacopy.problemState = appStatus.value;
                this.form1datacopy.problemStateName = appStatus.label;
            },
            getActivityData(row) {
                //console.log('aaa',row)
                this.form1datacopy.factorId = row.itemId
                this.form1datacopy.factorName = row.itemName
                this.form1datacopy.subitemId = row.subitemId
                this.form1datacopy.subitemName = row.subitemName
                this.expertSelectModal = false;
            },
            openExpertSelector() {
                this.expertSelectModal = true;
            },
            closeExpertSelectModal() {
                this.expertSelectModal = false;
            },
            setUserName1(data) {
                this.form1datacopy.executorName = data;
            },
            setUserId1(data) {
                this.form1datacopy.executorId = data[data.length - 1];
            },
            setUserName2(data) {
                this.form1datacopy.verifierName = data;
            },
            setUserId2(data) {
                this.form1datacopy.verifierId = data[data.length - 1];
            },
            selectMission(row) {
                //this.$refs.childUser.resetCurrentOrg();
                this.missionSelectModal = false
                this.form1datacopy = {
                    problemId: this.get_uuid(),
                    planTaskName: row.missionName,
                    planTaskId: row.missionId,
                    auditTime: new Date(),
                    auditedOrgName: row.auditedOrgName,
                    problemState: '0',
                    problemStateName: '待确认'
                };
                this.model11 = true;
                this.add = true;
            },
            beforeUpload(file) {
                let formData = new FormData();
                formData.append("files", file); // 文件对象
                let url = this.fileUrl + '/' + this.form1datacopy.problemId + '/files/adtProblems'
                this.$http.post(url, formData).then((res) => {
                    if (res.data.result == "success") {
                        this.$Message.info("文件上传成功")
                        this.getFiles(this.form1datacopy.problemId);
                    }
                })
                return false
            },
            getFiles(id) {
                this.upLoadList1.length = 0
                let url = this.fileUrl + '/' + id + '/files'
                let data = {field: 'adtProblems'}
                this.$http.get(url, {params: data}).then((res) => {
                    if (res.data.result == "success") {
                        if (res.data.data) {
                            this.upLoadList1 = res.data.data
                            this.upLoadList1 = this.upLoadList1.map(v => {
                                v.url = this.fileUrl + '/file/' + v.id;
                                return v
                            })
                        }
                    }
                })
            },
            openSelect() {
                this.missionSelectModal = true
            },
            handleFormatError(file) {
                this.$Message.error('格式不正确, 请上传 jpg 或 png');
            },
            handleMaxSize(file) {
                this.$Message.error('图片不能大于1M.');
            },
            handleBeforeUpload(file) {

                if (file.size > 1024 * 1024) {
                    this.$Message.error('图片不能大于1M.');
                    return false;
                }
                var index = file.name.lastIndexOf(".");
                var suffix = file.name.substr(index + 1);

                if (suffix != 'jpg' && suffix != 'jpeg' && suffix != 'png') {
                    this.$Message.error("请上传jpg,jpeg,png格式的图片");
                    return false;
                }

                const check = this.uploadImgs.length < 3;
                if (!check) {
                    this.$Message.error('最多上传3张图片');
                    return false;
                } else {
                    this.uploadImgs.push(file);
                }
                return false;
            },

            handleView(name, url) {
                console.log(111111, url)
                this.viewUrl = url;
                this.imgName = name;
                this.visible = true;
            },

            viewPicture(row) {
                //根据reportFile查询附件
                this.uploadList = [];
                this.$http.get(Api.uploadPTWFiles + '/' + row.reportFile + '/files', {params: {}}).then((res) => {
                    if (res.data.data != null) {
                        res.data.data.map((item) => {
                            this.uploadList.push({
                                name: item.fileName,
                                id: item.id,
                                url: Api.downloadPTWSchemeFile + '/' + item.id
                            });
                        });
                    }
                    //this.downloadUrl = this.downloadUrl + '/' + res.data.id;
                }).catch(e => {
                    console.log(e)
                    this.$Message.error("数据获取失败")
                })
            },

            viewAuditPicture(row) {
                //根据reportFile查询附件
                this.uploadImgs = [];
                this.$http.get(Api.uploadPTWFiles + '/' + row.assignId + '/files', {params: {}}).then((res) => {
                    if (res.data.data != null) {
                        res.data.data.map((item) => {
                            this.uploadImgs.push({
                                name: item.fileName,
                                id: item.id,
                                url: Api.downloadPTWSchemeFile + '/' + item.id
                            });
                        });
                    }
                    //this.downloadUrl = this.downloadUrl + '/' + res.data.id;
                }).catch(e => {
                    console.log(e)
                    this.$Message.error("数据获取失败")
                })
            },

            handleCancel() {
                this.model1 = false;
                this.model11 = false;
                this.model12 = false;

            },

            addInfo() {
                this.dataForm = {};
                this.setCurrentExpectUserName = {};
                this.setCurrentAssignUserName = {
                    label: JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserName"],
                    value: JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserId"]
                };
                setTimeout(() => {
                    this.$refs.childUser1.setCurrentUser();
                    this.$refs.childUser2.setCurrentUser();
                }, 300);
                this.model1 = true;
            },

            setExpectUserName(data) {
                this.dataForm.expectUserName = data;
            },
            setExpectUserId(data) {
                this.dataForm.expectUser = data[data.length - 1];
            },

            setAssignUserName(data) {
                this.dataForm.assignUserName = data;
            },
            setAssignUserId(data) {
                this.dataForm.assignUserId = data[data.length - 1];
            },

            pageChange(pageNum) {
                this.pagedata.currentPage = pageNum;
                this.query();
            },
            pageSizeChange(pageSize) {
                this.pagedata.pageSize = pageSize;
                this.query();
            },
            submit(name) {
                this.$refs[name].validate((valid) => {
                    if (valid) {
                        let userId = sessionStorage('userId').getObject('userId').userId;
                        let orgId = sessionStorage('userId').getObject('userId').orgInfo.orgId;
                        this.form1datacopy.updateUserId = userId;
                        this.form1datacopy.updateOrgId = orgId;

                        this.form1datacopy.problemState = '2'
                        this.form1datacopy.problemStateName = '待整改'

                        this.$http.post(Api.assginAdtProblemRect, this.form1datacopy).then((res) => {
                            if (res.status === 200) {
                                this.$Message.success('成功');
                                this.model12 = false;
                                this.query()

                            } else if (res.data.status === 201) {
                                this.$Message.error(res.data.msg);
                                this.model12 = false;
                            }

                        }).catch(e => {
                            this.model12 = false;
                            this.query();
                            this.$Message.error("数据获取失败")
                        })
                    } else {
                        this.$Message.error('请填报完整!');
                    }
                })
            },
            query() {
                this.buttonLoading = true
                let data = {
                    currentPage: this.pagedata.currentPage,
                    size: this.pagedata.pageSize,
                    userId: JSON.parse(sessionStorage('userId').get('userId'))
                }

                if (this.form1.rpoblemDesc) {
                    data.rpoblemDesc = this.form1.rpoblemDesc
                }
                if (this.form1.problemState) {
                    data.problemState = this.form1.problemState
                }

                data = Object.assign(data, JSON.parse(JSON.stringify(this.form1)));
                //data.problemState = '1'
                data.createUserId = sessionStorage('userId').getObject('userId').userId
                let url = Api.queryAdtRectProblem;
                this.$http.get(url, {params: data}).then((res) => {
                    if (res.data.data) {
                        this.dataTable = res.data.data;
                        this.pagedata.total = res.data.totalSize;
                        this.buttonLoading = false
                    }
                }).catch(e => {
                    console.log(e)
                    this.$Message.error("数据获取失败")
                })

            },
            reset() {
                this.form1 = {};
                this.query();
            },

            deleteData(params) {
                let url = Api.deleteAdtProblem;
                this.$http.get(url, {params: {id: params.row.problemId}}).then((res) => {
                    if (res.status === 200) {
                        this.$Message.success('成功');
                        this.query()
                    } else if (res.data.status === 201) {
                        this.$Message.error(res.data.msg);

                    }
                }).catch(e => {
                    this.$Message.error('请求失败' + e);
                })
            },
            formatDate(date, fmt) {
                if (/(y+)/.test(fmt)) {
                    fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
                }
                let o = {
                    'M+': date.getMonth() + 1,
                    'd+': date.getDate(),
                    'h+': date.getHours(),
                    'm+': date.getMinutes(),
                    's+': date.getSeconds()
                };
                for (let k in o) {
                    if (new RegExp(`(${k})`).test(fmt)) {
                        let str = o[k] + '';
                        fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : this.padLeftZero(str));
                    }
                }
                return fmt;
            },
            padLeftZero(str) {
                return ('00' + str).substr(str.length);
            },
            get_uuid() {
                let s = [];
                let hexDigits = "0123456789abcdef";
                for (let i = 0; i < 36; i++) {
                    s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
                }
                s[14] = "4";
                s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);
                s[8] = s[13] = s[18] = s[23] = "-";

                let uuid = s.join("");
                let reg = new RegExp("-", "g");
                let a = uuid.replace(reg, "");
                console.log(a);
                return a;
            },
            remove1(mainId, id) {
                let url = this.fileUrl + '/file/' + id;
                this.$http.delete(url).then((res) => {
                    this.getFiles(mainId)
                })
            },
            showData(data, flag) {
                this.getFiles(data.row.problemId)
                if (flag == 1) {
                    this.showdata = data.row;
                    this.model3 = true;
                } else {
                    this.add = false;
                    this.form1datacopy = JSON.parse(JSON.stringify(data.row));
                    this.form1datacopy.rectDeadLine = new Date()
                    this.model12 = true;
                }
            },
        },

        watch: {
            "model11": function (qw, er) {
                if (qw && this.model11) {
                    setTimeout(() => {
                        this.$refs.childUser1.setCurrentOrg();
                    }, 100)
                } else {
                    //this.$refs.childUser.setCurrentUser();
                }
            },
        },

    }
</script>
<style lang='css' scoped>
    @import '../../../index.css';
</style>
